import type { BaseData } from "../datavo/DataCustom";
import type { SpineManage } from "./anim/SpineManage";
import type BadgeManage from "./badge/BadgeManage";
import type DataManage from "./db/DataManage";
import type LocalDb from "./db/LocalStorage";
import type EventManage from "./event/EventManage";
import type UIManage from "./gui/UIManage";
import type GuideManage from "./guide/GuideManage";
import type SoundManage from "./sound/SoundManage";
import type TimeManage from "./time/TimerManage";
import type { Platform } from "./platform/Platform";
import type Net from "./net/Net";
import Context from "./context/Context";

export default class game {

    static ui: UIManage;
    static evm: EventManage;
    static badge: BadgeManage;
    static db: LocalDb;
    static data: DataManage;
    static guide: GuideManage;
    static net: Net;
    static sound: SoundManage;
    static time: TimeManage;
    static spine: SpineManage;
    static app: Platform;

    static get context() {
        return Context.Instance;
    }

    static get<T extends object>(c: new (...ages: any[]) => T): T {
        return this.context.get(c);
    }

    static openui(...arg: Parameters<typeof game.ui.open>) {
        this.ui.open(...arg);
    }

    static popupui(...arg: Parameters<typeof game.ui.popup>) {
        this.ui.popup(...arg)
    }

    static event(...arg: Parameters<typeof game.evm.event>) {
        this.evm.event(...arg);
    }

    static on(...arg: Parameters<typeof game.evm.on>) {
        this.evm.on(...arg);
    }

    static getItem(...arg: Parameters<typeof game.db.getItem>) {
        return this.db.getItem(...arg);
    }

    static getItemAsNum(...arg: Parameters<typeof game.db.getItemAsNum>) {
        return this.db.getItemAsNum(...arg);
    }

    static setItem(...arg: Parameters<typeof game.db.setItem>) {
        this.db.setItem(...arg);
    }

    static getData<T extends BaseData>(c: new () => T) {
        return this.data.getData(c);
    }

    static findDataById<T extends BaseData>(c: new () => T, id: number) {
        return this.data.findOneByID(c, id)
    }

    static findDataOne<T extends BaseData>(c: new () => T, key: keyof T, value: any) {
        return this.data.findOne(c, key, value);
    }


    static get saveTime() {
        return this.time.second;
    }

    static get saveTimeMs() {
        return this.time.ms;
    }

    static get width() {
        return Laya.stage.width;
    }

    static get height() {
        return Laya.stage.height;
    }

    static set mouseEnable(v: boolean) {
        Laya.stage.mouseEnabled = v;
    }

    static get second() {

        return this.time.second;
    }
}